<?php
defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.view');

class OwnserviceViewTodayTransactions extends JView
{
	function display($tpl = null)
	{
		global $mainframe, $option;
		
		//Initialise variables
		$document	= & JFactory::getDocument();
		$user		= & JFactory::getUser();
		$db			= & JFactory::getDBO();
		$ownuser	= & Ownservice::getUser();
		$params 	= & $mainframe->getParams('com_ownservice');
		$pathway  	= & $mainframe->getPathway();
		
		//Set page title information
		$menus		= &JSite::getMenu();
		$menu		= $menus->getActive();
		
		//add css to document
		$document->addStyleSheet(JURI::base().'components/com_ownservice/assets/css/style.css');
		$document->addStyleSheet(JURI::base().'components/com_ownservice/assets/css/nav.css');
		$document->addStyleSheet(JURI::base().'components/com_ownservice/assets/css/icon.css');
		
		$filter_order		= $mainframe->getUserStateFromRequest($option.'.todaytransaction.filter_order', 'filter_order', 't.created', 'cmd');
		$filter_order_Dir	= $mainframe->getUserStateFromRequest($option.'.todaytransaction.filter_order_Dir', 'filter_order_Dir', 'DESC', 'cmd');
		$search				= $mainframe->getUserStateFromRequest($option.'.todaytransaction.search', 'search', '', 'string' );
		if (strpos($search, '"') !== false) {
			$search = str_replace(array('=', '<'), '', $search);
		}
		$search = JString::strtolower($search);
		
		//get data from the model
		$model 	= $this->getModel();
		$rows 	= & $this->get('Data');
		$total	= & $this->get('Total');
		$pageNav= & $this->get('Pagination');
		
		// because the application sets a default page title, we need to get it
		// right from the menu item itself
		if (is_object( $menu )) {
			$menu_params = new JParameter( $menu->params );
			if (!$menu_params->get( 'page_title')) {
				$params->set('page_title',	JText::_('OWNSERVICE_TODAYS_TRANSACTIONS'));
			}
		} else {
			$params->set('page_title',	JText::_('OWNSERVICE_TODAYS_TRANSACTIONS'));
		}
		$document->setTitle( $params->get( 'page_title' ) );

		//Set pathway information
		$pathway->addItem($poll->title, '');

		$params->def( 'show_page_title', 1 );
		$params->def( 'page_title', $poll->title );
		
		$lists = array();

		//search filter
		$lists['search']= $search;
		
		$lists['order']     = $filter_order;
		$lists['order_Dir'] = $filter_order_Dir;
		
		//assign data to document
		$this->assignRef('rows', $rows);
		$this->assignRef('pageNav', $pageNav);
		$this->assignRef('lists', $lists);
		$this->assignRef('params', $params);
		$this->assignRef('db', $db);
		
		parent::display($tpl);
	}
}
